package it.unibo.mumu;

import it.unibo.mumu.R;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SmallPlanet extends LinearLayout {

	private int idPlanet;
	private String labelText;
	private Point position;

	private TextView labelView;
	private ImageView planetImageView;
	private int screenW;
	private int screenH;

	public SmallPlanet(Context context) {
		this(context, -1, "Pianeta Vuoto", new Point(-1, -1));
	}

	public SmallPlanet(Context context, AttributeSet attrs) {
		super(context, attrs);
		
	}
	
	public SmallPlanet(Context context, int id, String label, Point position) {
		super(context);

		this.idPlanet = id;
		this.labelText = label;
		this.position = position;

		this.setOrientation(VERTICAL);
		LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		llp.gravity = Gravity.CENTER;
		
		this.planetImageView = new ImageView(getContext());
		this.planetImageView.setImageResource(R.drawable.planet_small);
		
		this.labelView = new TextView(getContext());
		this.labelView.setText(label);
		this.labelView.setTextColor(Color.WHITE);
		
		this.addView(planetImageView, llp);
		this.addView(labelView, llp);
		
	}

	@Override
	 protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld){
	     super.onSizeChanged(xNew, yNew, xOld, yOld);

	     screenW = xNew;
	     screenH = yNew;
	     
	}
	
	public int getLeftMargin() {
		return this.position.x;
	}

	public int getTopMargin() {
		return this.position.y;
	}

	public int getIdPlanet() {
		return idPlanet;
	}

	public void setIdPlanet(int id) {
		this.idPlanet = id;
	}

	public String getLabelText() {
		return labelText;
	}

	public void setLabelText(String label) {
		this.labelText = label;
	}

	public Point getPosition() {
		return position;
	}

	public void setPosition(Point position) {
		this.position = position;
	}

	public int getScreenW() {
		return screenW;
	}

	public int getScreenH() {
		return screenH;
	}

}
